import * as Utils from 'utils.js';

//图片路径处理
export function setImageUrl(GoodImagePath) {
	//ip
	var ip = uni.getStorageSync("ip");
	//端口
	var ipPost = uni.getStorageSync("ipPost");

	if (GoodImagePath == "") {
		return '/static/default1.jpg';
	} else {
		let path = "http://" + ip;
		if (ipPost != "") {
			path += ":" + ipPost;
		}
		console.log(path + "/picture" + GoodImagePath);
		return path + "/picture" + GoodImagePath;
	}
}


//提示框
export function showTip(msg) {
	uni.showToast({
		position: 'bottom',
		title: msg,
		duration: 1000,
		style: "z-index:9999",
	});
};
//确认框
export function showConfirm(msg, sureClick) {
	uni.showModal({
		title: '提示',
		content: msg,
		success: function(res) {
			if (res.confirm) {
				sureClick(true);
			} else if (res.cancel) {
				sureClick(false);
			}
		}
	});
}

//保留两位小数
export function setTwoFloat(num) {
	return Math.round(num * 100) / 100;
}

//查询订单
export function SelectBillOrderMaster(arr, callBack) {
	let url = Utils.getPostIp("/api/Select_Bill_Order_Master");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}




//查询订单明细
export function SelectBillOrderDetail(arr,callBack) {
	let url = Utils.getPostIp("/api/Select_Bill_Order_Detail");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}


//查询订单 (采购入库单，采购退货单，销售出库单，销售退货单，调拨单，其他入库单，其他出库单 ，配送申请单，配送出库单，配送退回单，POS单)
export function SelectBillMaster(arr,callBack) {
	let url = Utils.getPostIp("/api/Select_Bill_Master");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//查询订单明细(采购入库单，采购退货单，销售出库单，销售退货单，调拨单，其他入库单，其他出库单 ，配送申请单，配送出库单，配送退回单，POS单)
export function SelectBillDetail(arr,callBack) {
	let url = Utils.getPostIp("/api/Select_Bill_Detail");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//查询订单(收款单，付款单，会员充值)
export function SelectBillPay(arr,callBack) {
	let url = Utils.getPostIp("/api/Select_Bill_Pay");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

//查询订单明细(收款单，付款单，会员充值)
export function SelectBillPayDetail(arr,callBack) {
	let url = Utils.getPostIp("/api/Select_Bill_Pay_Detail");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//查询订单 (盘点单)
export function SelectBillInventory(arr,callBack) {
	let url = Utils.getPostIp("/api/Select_Bill_Inventory");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//查询订单明细 (盘点单)
export function SelectBillInventoryDetail(arr,callBack) {
	let url = Utils.getPostIp("/api/Select_Bill_Inventory_Detail");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

//删除采购销售促销订单
export function DeleteBillOrder (arr,callBack) {
	let url = Utils.getPostIp("/api/Delete_Bill_Order ");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "POST", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}


//删除(采购入库单，采购退货单，销售出库单，销售退货单，调拨单，其他入库单，其他出库单 ，配送申请单，配送出库单，配送退回单，POS单)
export function Delete_Bill(arr,callBack) {
	let url = Utils.getPostIp("/api/Delete_Bill");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "POST", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//删除(收款单，付款单，会员充值)
export function Delete_Bill_Pay(arr,callBack) {
	let url = Utils.getPostIp("/api/Delete_Bill_Pay");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "POST", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//删除(盘点单)
export function Delete_Bill_Inventory (arr,callBack) {
	let url = Utils.getPostIp("/api/Delete_Bill_Inventory");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "POST", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}